# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

MY_P=${P/0./}
MY_P=${MY_P/-/.}

DESCRIPTION="Digital Mars D Programming Language Compiler"
HOMEPAGE="http://www.digitalmars.com/d/"
SRC_URI="ftp://ftp.digitalmars.com/${MY_P}.zip"
LICENSE="DMD"
RESTRICT="mirror"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE=""
RDEPEND=""
DEPEND="${RDEPEND}
	virtual/libc
	>=sys-devel/gcc-2.3.0
	amd64? ( app-emulation/emul-linux-x86-compat )"
S="${WORKDIR}"

src_install() {
	dobin dmd/bin/dmd
	dobin dmd/bin/dumpobj
	dobin dmd/bin/obj2asm
	doman dmd/man/man1/dmd.1
	doman dmd/man/man1/dumpobj.1
	doman dmd/man/man1/obj2asm.1

	dolib.a dmd/lib/libphobos.a
	dodir /usr/lib/phobos
	(cd dmd/src/phobos; find -name '*.d' | grep -v unittest.d$ | xargs tar c) | \
		(cd "${D}/usr/lib/phobos"; tar xo)

	dohtml -r dmd/html/*
	dodoc dmd/license.txt dmd/src/phobos/phoboslicense.txt

	dodir /etc
	cat <<EOF > "${D}/etc/dmd.conf"
[Environment]
DFLAGS=-I/usr/lib/phobos
EOF
}
